'''python常用数据结构'''
'''生成式（推导式）'''
prices = {
    'APPL': 191.88,
    'GOOG': 1186.96,
    'IBM': 149.24,
    'ORCL': 48.44
}
# 用股票价格大于100的股票构成一个新的字典
prices2 = {key: value for key, value in prices.items() if value > 100}
print(prices2)


'''比较列表和字典的包含操作'''
import timeit
import random

for i in range(10000, 100001, 20000):
    t = timeit.Timer("random.randrange(%d) in x" % i, "from __main__ import random,x")
    x = list(range(i))
    lst_time = t.timeit(number=1000)
    x = {j: None for j in range(i)}
    d_time = t.timeit(number=1000)
    print("%d,%10.3f,%10.3f" % (i, lst_time, d_time))
